package org.jash.sportnews2109.ui

import com.alibaba.android.arouter.facade.annotation.Route
import dagger.hilt.android.AndroidEntryPoint
import org.jash.common.adapter.CommonAdapter
import org.jash.common.mvvm.BaseFragment
import org.jash.sportnews2109.BR
import org.jash.sportnews2109.R
import org.jash.sportnews2109.databinding.FragmentBookmarkBinding
import org.jash.sportnews2109.entity.News
import org.jash.sportnews2109.vm.BookmarkViewModel


@Route(path = "/news/bookmark")
@AndroidEntryPoint
class BookmarkFragment : BaseFragment<FragmentBookmarkBinding, BookmarkViewModel>() {
    val adapter by lazy { CommonAdapter<News>(R.layout.news_item, BR.news) }
    override fun initView() {
        binding.recycler.adapter = adapter
    }

    override fun initData() {
        viewModel.newsLiveData.observe(this, this::load)
        viewModel.loadMyCollect()
    }
    fun load(list: List<News>) {
        adapter += list
    }

}